package com.ljfiction.book.adapter;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;

import android.view.View;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ljfiction.book.Baner.BookCommentBean;

import com.ljfiction.book.Baner.HotConmmentBean;
import com.ljfiction.book.R;
import com.ljfiction.book.tools.ScreenUtils;
import com.ljfiction.book.tools.TimeTool;
import com.zhy.autolayout.utils.AutoUtils;

import java.util.List;



/**
 * Created by admin on 2017/8/9.
 */

public class ConmmentDatasAdapter extends BaseQuickAdapter<HotConmmentBean.DataBean,BaseViewHolder> {


    public ConmmentDatasAdapter(@LayoutRes int layoutResId, @Nullable List<HotConmmentBean.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, HotConmmentBean.DataBean item) {
        AutoUtils.autoSize(helper.itemView);
        helper.setText(R.id.usercomment,item.getCommentContext())
                .setText(R.id.authername_datascomment,item.getPseudonym())
                .setText(R.id.bookdatasshupingtime, TimeTool.getTimeAndChange(String.valueOf(item.getCommentDateTime())))
                .setText(R.id.zan_bookdatacomment,"回复 "+String.valueOf(item.getReplyCount()))
                .setText(R.id.grade_commentuser,"LV"+item.getUserGrade())
                .setText(R.id.reply_bookdatas,"赞 "+String.valueOf(item.getThumbsCount()));
        Glide.with(mContext).load(item.getUserHeadPortraitURL()).override(ScreenUtils.getNum(mContext,38),ScreenUtils.getNum(mContext,38)).into((ImageView) helper.getView(R.id.commentuserimag));
        if (item.getUserSex()==0){
            ((ImageView) helper.getView(R.id.seximag_datascomment)).setImageResource(R.mipmap.sex_n);
        }else {
            ((ImageView) helper.getView(R.id.seximag_datascomment)).setImageResource(R.mipmap.sex_v);
        }
        if (item.getVipGrade()>0){
            helper.getView(R.id.huangguan_bookdatascomment).setVisibility(View.VISIBLE);
        }else {
            helper.getView(R.id.huangguan_bookdatascomment).setVisibility(View.GONE);
        }
        helper.addOnClickListener(R.id.commentuserimag);
    }
}
